home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11651 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  946 b 

  1. Path: krel.iea.com!usenet
  2. From: fleckm@comtch.iea.com@iea.com
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Limiting stdin input to "n" chars
  5. Date: 25 Mar 1996 15:51:05 GMT
  6. Organization: CompuTech
  7. Message-ID: <4j6fd9$3o4@krel.iea.com>
  8. References: <4hqfmc$un7@thorn.cc.usm.edu> <4icer1$df5@altrade.nijmegen.inter.nl.net> <4if7k6$9ro@news.xs4all.nl> <4j1i39$jso@nntp1.best.com>
  9. Reply-To: fleckm@comtch.iea.com@iea.com
  10. NNTP-Posting-Host: cda0-10.iea.com
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4j1i39$jso@nntp1.best.com>, Zenin <zenin@best.com> writes:
  14. >    What I'm trying to do is simply ask a y/n question of the user so
  15. >    that they only have to enter "y" or "n" without having to also give
  16. >    the anoying line feed.
  17. >
  18. >    I thought simply
  19. >        int c;
  20. >        c = getchar();
  21. >        if (c ==...etc...
  22. >    would do it, but of course I'm wrong... :(
  23.  
  24. You could try:
  25.  
  26. char ch;
  27.  
  28. ch=getch();
  29.  
  30. if (ch='Y' || ch='y') // allow lower or upper case
  31. {
  32. stuff
  33. }
  34.  
  35.  
  36. Mike in Coeur d'Alene
  37.